
//初始值
export const initState = {
  //初始化数据
  //新人专享
  news:[],
  //秒杀
  seckill:[],
  //万人团
  groupon:[],
  //倒计时
  countdown:[],
  //商品信息首页
  indexgoods:[],
  //导航标识
  flag:1,
  //优惠卷
    coupon:[]
};

//reducer 修改数据
export const reducer = (state = initState, action) => {
  switch (action.type) {
    // 新人专享
    case 'changeNews':
      return {
        ...state,
        news: action.news,
      };
    //秒杀
    case 'changeSeckill':
        return{
            ...state,
            seckill:action.seckill,
        };
    // //万人团
    case 'changeGroupon':
        return{
            ...state,
            groupon:action.groupon,
        };
    // //倒计时
    case 'changeCountdown':
        return{
            ...state,
            countdown:action.countdown,
        };
     ////商品信息首页
    case 'changeIndexgoods':
        return{
             ...state,
            indexgoods:action.indexgoods,
        };
    case 'changeFlag':
        return{
             ...state,
            flag:action.flag,
        };  
    //   // 优惠卷 
    case 'changeCoupon':
        return{
            ...state,
            coupon:action.coupon,
        };
    default:
      return state;
  }
};
//actionCreators组件派发的动作
export const actions = {
  //新人专享
  changeNews: (news) => ({ type: 'changeNews', news}),
  //秒杀
  changeSeckill: (seckill) => ({ type: 'changeSeckill', seckill}),
   //万人团
changeGroupon: (groupon) => ({ type: 'changeGroupon', groupon}),
   //倒计时
changeCountdown: (countdown) => ({ type: 'changeCountdown', countdown}),
  //商品信息首页
changeIndexgoods: (indexgoods) => ({ type: 'changeIndexgoods', indexgoods}),
   //导航标识
   changeFlag: (flag) => ({ type: 'changeFlag', flag}),
  //优惠券
   changeCoupon: (coupon) => ({ type: 'changeCoupon', coupon})
// 
  //请求 异步操作
  //
//  
//  
// 
//  
//  
};


